<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/resource/css/write.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/jquery1.4.js"></script>
<script type="text/javascript">
      var jQuery_1_3_2 = $.noConflict(true);
</script>
<script type="text/javascript" src="${pageContext.request.contextPath}/xheditor/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/xheditor/xheditor-1.2.1.min.js"></script>
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/xheditor/xheditor_lang/zh-cn.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <link type="text/css" rel="Stylesheet" href="${pageContext.request.contextPath}/resource/css/admin-main.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/csdn.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/master.js"></script>
 <link rel="Stylesheet" href="${pageContext.request.contextPath}/resource/css/index.css" type="text/css"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/bioV4.min.js"></script>
<script type="text/javascript"src="${pageContext.request.contextPath}/resource/js/jquery.lazyload.mini.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/function.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/list.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/biobox.js"></script>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resource/css/basic.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resource/css/list1.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resource/css/login.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resource/css/comment.css" />
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/resource/css/biobox2.css" />

<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resource/css/nav_login_head.css" />
 
 
 
<style type="text/css">
#ol_img {
	margin: 0px 12px;
	padding: 10px;
}

#ol_img li {
	list-style-type: decimal;
}

#ol_img li a {
	margin-left: 10px;
}
.btnCode {
	background: transparent url(${pageContext.request.contextPath}/resource/images/code.png) no-repeat 0px 0px;
	background-position: 3px -2px;
	}
</style>
<script type="text/javascript">
	$(function(){
		   var plugins={
				Code:{c:'btnCode',t:'插入代码',h:1,e:function(){
					var _this=this;
					var htmlCode="<div>编程语言<select id='xheCodeType'>";
						htmlCode+="<option value='html'>HTML/XML</option>";
						htmlCode+="<option value='js'>Javascript</option>";
						htmlCode+="<option value='css'>CSS</option>";
						htmlCode+="<option value='php'>PHP</option>";
						htmlCode+="<option value='java'>Java</option>";
						htmlCode+="<option value='py'>Python</option>";
						htmlCode+="<option value='pl'>Perl</option>";
						htmlCode+="<option value='rb'>Ruby</option>";
						htmlCode+="<option value='cs'>C#</option>";
						htmlCode+="<option value='c'>C++/C</option>";
						htmlCode+="<option value='vb'>VB/ASP</option>";
						htmlCode+="<option value=''>其它</option>";
						htmlCode+="</select></div><div>";
						htmlCode+="<textarea id='xheCodeValue' wrap='soft' spellcheck='false' style='width:300px;height:100px;' />";
						htmlCode+="</div><div style='text-align:right;'><input type='button' id='xheSave' value='确定' /></div>";			
					var jCode=$(htmlCode),jType=$('#xheCodeType',jCode),jValue=$('#xheCodeValue',jCode),jSave=$('#xheSave',jCode);
					jSave.click(function(){
						_this.loadBookmark();
						_this.pasteHTML('<pre>'+_this.domEncode(jValue.val())+'</pre>&nbsp;');
						_this.hidePanel();
						return false;	
					});
					_this.saveBookmark();
					_this.showDialog(jCode);
				}},
				
			};
			$('#articleContent').xheditor({
					plugins:plugins,  //使用我们定义的插件  
					loadCSS:'<style>pre{margin-left:2em;border-left:3px solid #CCC;padding:0 1em;}</style>',
			});
		
		})
</script>

<title>文章添加</title>
</head>
<body>

	<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/borsertocss.js">
		
	</script>
	<!-- 判断在IE9以下浏览器中根据像素的不同而设置的样式 -->

	<div class="navbar navbar-fixed-top"
		style="_position: relative;_z-index: 10000;">
		<div class="navbar-inner">
			<div class="container">
				<div style="ont-family:Arial; font-size:14px;">
					<ul class="nav">
						<li class=""><a href="${pageContext.request.contextPath}/user/webDefault.jsp"><b>首页</b></a></li>
						<li class=""><a href="${pageContext.request.contextPath}/user/webColumn.jsp"><b>博客专栏</b></a></li>
						<li class=""><a href="${pageContext.request.contextPath}/user/webAuthor.jsp"><b>博客专家</b></a></li>
						<li class=""><a href="${pageContext.request.contextPath}/user/webRank.jsp"><b>博客排行榜</b></a></li>
						<li class=""><a href="${pageContext.request.contextPath}/ArticleSer"><b>我的博客</b></a></li>
					</ul>
				</div>
				<!--/.nav-collapse -->
				<ul id="userInfo" class="nav pull-right login-none nav-tips">
					<li class="ie6png divider-vertical"
						style="_width: 30px;_height: 40px;_background: url(${pageContext.request.contextPath}/resource/images/icons.png) no-repeat 10px -106px;"><a
						class="dropdown-toggle clearfix" style="padding: 7px 5px;"><img
							class="logo-before pull-left"
							src="/MyBlog/resource/images/avatar-icon.png" /></a></li>
				</ul>

				<ul id="Relog" class="nav pull-right pl-20 myul">
					<li class=""><a href="${pageContext.request.contextPath}/user/userRegister.jsp">注册</a></li>
					<li class="l10"><a href="${pageContext.request.contextPath}/user/userLogin.jsp">登录</a></li>
				</ul>
				
			<div class="member">
			<p>会员中心</p>
			<ul>
				<li>
					<img src="${pageContext.request.contextPath}/resource/images/nav_login_huiyuan1.png" alt="">
					<a href="login.html">个人主页</a>
				</li>
				<li>
					<img src="${pageContext.request.contextPath}/resource/images/nav_login_huiyuan1.png" alt="">
					<a href="register.html">管理</a>
				</li></ul><span>
				<a href="${pageContext.request.contextPath}/UserSer?tag=logout" class="logoutBtnxxxx">退出登录</a></span>

		</div>
<!-- 点击登录,判断是否存在session,若存在,下滑什么鬼框
	  登出,把注册|登录显示,把用户信息和什么鬼框隐藏
 -->
<script type="text/javascript">
$(function() {
	/*登录*/
	$("#userInfo").click(function(){
		var name = "${sessionScope.user}";
		if(name != "") {
			$(".member").slideToggle(300);
		}
	});
	
	/*登出*/
	$(".logoutBtn").click(function(){
		$("#Relog").css('display','block');
		$("#userInfo").css('display','none');
		$(".member").css('display','none');
	});

});
</script>
		
				
			</div>
		</div>
	</div>
<!-- 这是判断是否登录的信息，需要用到jquery1.4.js -->
<script type="text/javascript">
	$(function getUser(){
 		var name = "${sessionScope.user}";
		if(name != "") {
			$("#Relog").css('display','none');
			$("#userInfo").css('display','block');
		}
	});
	</script>
	<!--头部代码结束-->

	<div id="wrap">
		<form action="${pageContext.request.contextPath}/ArticleSer?tag=addpost" method="post">
			<jsp:include page="../inc/tabs_header.jsp"></jsp:include>
			<p>
				<a href="${pageContext.request.contextPath}/user/postList.jsp">我的博客</a>
				>> 发布文章
			</p>
			<p class="subtit">文章标题</p>
			<div>
				<select id="selType" style="height:30px;width:120px" name="articleType">
					<option value="公开" >请选择模式</option>
					<c:choose>
					<c:when test="${postedit.articleType.equals('公开')}">
					<option value="私有" >私有</option>
					<option value="公开" selected="selected">公开</option>
					</c:when>
					<c:otherwise>
					<option value="私有" selected="selected">私有</option>
					<option value="公开" >公开</option>
					</c:otherwise>
					</c:choose>
				</select>
				<select id="selType" style="height:30px;width:120px" name="articleCat">
					<option value="1">请选择分类</option>
				<c:forEach items="${catList}" var="c" >
					<c:choose>
						<c:when test="${postedit.articlecat.sortId == c.sortId}">
							<option value="${c.sortId}" selected="selected">${c.sortName}</option>
						</c:when>
						<c:otherwise>
							<option value="${c.sortId}">${c.sortName}</option>
						</c:otherwise>
					</c:choose>
				</c:forEach>
				</select>
				 <input type="text" id="txtTitle" style="width:560px; float:left;"
					maxlength="100" name="articleTitle" value="${postedit.articleTitle}"/>
			</div>
			<p class="subtit">文章内容</p>
			<div class="section">
				<textarea  rows="20" cols="80" style="width: 100%" id="articleContent" name="articleContent">${postedit.articleContent}
		</textarea>
				<br />
			</div>

			<input type="hidden" value="${postedit.articleId}" name="articleId"/>
				
			<fieldset style="margin-top: 10px; padding: 4px 10px 10px 10px; border-color:#AAAAAA">
				<legend>上传图片</legend>
				<table border="0" cellpadding="0" cellspacing="0"
					style="width: 100%;">
					<tr>
						<td valign="top">
							<ol id="ol_img"></ol>
							<p id="p_err" style="color: Red;"></p>
						</td>
						<td rowspan="2" valign="top" style="width: 240px;">
							<div
								style="border: solid 1px #999; background-color: #f0f0f0; font-size: 11px; padding-left: 10px;">
								<p>
									1、图片大小不能超过<b>2M</b>
								</p>
								<p>2、支持格式：.jpg .gif .png .bmp</p>
							</div>
						</td>
					</tr>
					<tr>
						<td valign="bottom">
						<iframe id="frm_img_2" name="frm_img_2"
								src="${pageContext.request.contextPath}/inc/uploadImg.jsp" frameborder="0" scrolling="no"
								style="width: 390px; height: 24px; float: left;"></iframe> 
								<input type="button" value="上传" style="float: left; _padding: 2px 2px;" 
								onclick="uploadImg2(this)" />（上传后可点击[插入]加入文章中）</td>
					</tr>
				</table>
			</fieldset>
	<script type="text/javascript">
	
	
	//获取当前网址，如： http://localhost:8080/Tmall/index.jsp 
	var curWwwPath=window.document.location.href; 

	//获取主机地址之后的目录如：/Tmall/index.jsp 
	var pathName=window.document.location.pathname; 
	var pos=curWwwPath.indexOf(pathName); 

	//获取主机地址，如： http://localhost:8080 
	var localhostPaht=curWwwPath.substring(0,pos); 

	//获取带"/"的项目名，如：/Tmall 
	var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1); 
	
	//获取xheditor插件
	
    function showErr2(msg) {
        $("#p_err").html("* " + msg);
    }
    function setPath2(url) {
    	if (url != null && url != "") {
    		var newurl = "${pageContext.request.contextPath}"+ url ;
     		var li = "<li><span>" + newurl + "</span><a href='#' onclick='javascript:insertImage2(this);return false;'>[插入]</a></li>";
     		$("#ol_img").append($(li));
    	}
    }
    function uploadImg2(e) {      
        window.frames["frm_img_2"].document.forms[0].submit();
    }
    function insertImage2(e) {
    	
        var url = e.previousSibling.innerHTML;
        var str = "<img src='" + url +"' />";
        $('#articleContent').xheditor().appendHTML(str);
    }
</script>



			<p id="p_desc" class="subtit">
				摘要：<span class="gray">（默认自动提取您文章的前200字显示在博客首页作为文章摘要，您也可以在这里自行编辑
					）</span>
			</p>
			<div id="d_desc">
				<textarea id="txtDesc" rows="6" style="width:99%;" name="articleRoundup">${postedit.articleRoundup}</textarea>
			</div>
			
			
			<p id="p_desc" class="subtit">
				选择专栏：<span class="gray">
					）</span>
			</p>
			<div id="d_desc">
			<select name="columnId" >
			<c:forEach items="${listScol}" var="list"> 
				<option>${list.columnName }</option>
				<c:choose>
						<c:when test="${postedit.getColumn().getColumnId() == list.columnId}">
							<option value="${list.columnId}" selected="selected">${list.columnName}</option>
						</c:when>
						<c:otherwise>
							<option value="${list.columnId}">${list.columnName}</option>
						</c:otherwise>
					</c:choose>
				</c:forEach>
				</select>
				
			</div>


			<div class="btn_area_1">
				<input  type="submit" class="input_btn_1" value="发表文章" title="保存并跳转" /> 
				 <input  type="reset" class="input_btn_1" value="舍弃" /> 

			</div>



		</form>
	</div>
	<jsp:include page="../inc/footer_nav.jsp"></jsp:include>
</body>
</html>
